<?php
class sitesModel extends model{
	public $base;
	public function __construct(&$base){
		parent::__construct($base);
		$this->base=$base;
		$this->table="sites";
	}
	
	 
	
	public function getByIds($ids){
		if(empty($ids)) return false;
		$data=$this->select(array(
			"where"=>" siteid in("._implode($ids).")"
		));
		foreach($data as $v){
			$ndata[$v['siteid']]=$v;
			
		}
		return $ndata;
	}
	
	public function getListBycityidIds($ids){
		if(empty($ids)) return false;
		$data=$this->select(array(
			"where"=>"   cityid in("._implode($ids).")"
		));
		foreach($data as $v){
			$ndata[$v['siteid']]=$v;
			
		}
		return $ndata;
	}
	
	
	public function getIdsByCity($cityid){
		$citys=M("options")->select(array(
			"where"=>" tablename='sitearea' AND id=".$cityid." "
		));
		if($citys){
			foreach($citys as $v){
				$cityids[]=$v['id'];
				$child=M("options")->select(array(
						"where"=>" tablename='sitearea' AND pid=".$v['id']." "
				));
				if($child){
					foreach($child as $vv){
						$cityids[]=$vv['id'];
					}
				}
			}
			
			return $this->selectCols(array(
				"where"=>" cityid in("._implode($cityids).")",
				"fields"=>"siteid"
			));
			
		}
		
		
	}
}
 
?>